String.prototype.endswith = function(suffix) {
    return this.indexOf(suffix, this.length - suffix.length) !== -1;
};

var _request_disabled_items = [];
$(document).ajaxStart(function() {
	$.each(_request_disabled_items, function(i, $n) {
		$n.attr("disabled", true);
	});
});

$(document).ajaxStop(function() {
    $.each(_request_disabled_items, function(i, $n) {
        $n.attr("disabled", false);
    });
    _request_disabled_items = [];
});

// ajax请求期间需要自动设置为不可用的便捷方法
function add_request_disabled_control($n) {
	_request_disabled_items.push($n);
}